package com.atguigu.gulimall.product.web;

import com.alibaba.fastjson.JSON;
import com.atguigu.gulimall.product.model.vo.SkuItemVo;
import com.atguigu.gulimall.product.service.CategoryService;
import com.atguigu.gulimall.product.service.SkuInfoService;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

@Controller
public class ItemController {
    @Autowired
    private CategoryService categoryService;

    @Autowired
    private RedissonClient redisson;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private SkuInfoService skuInfoService;

    @GetMapping({"/{skuId}.html"})
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {
        SkuItemVo itemVo = skuInfoService.item(skuId);
        System.out.println(JSON.toJSON(itemVo));
        model.addAttribute("item",itemVo);
        return "item";
    }
}
